def get_department_tree(departments, parent_id=0):
    """树桩数据组装"""
    tree = []
    for department in departments:
        if department['resource_rid'] == parent_id:
            department['children'] = get_department_tree(departments, department['resource_id'])
            tree.append(department)
    return tree
